using UnityEngine;

public class Piece_item : MonoBehaviour
{
	public UIEventListener itembtn;

	public PieceData curpiecedata;

	public UISprite pieceflag;

	public UILabel piecenumlabel;

	public UISprite piecekuang;

	public void enable(PieceData pd, int num = 1)
	{
		curpiecedata = pd;
		pieceflag.spriteName = "GY_SP_" + pd.id;
		if (piecenumlabel != null)
		{
			piecenumlabel.text = string.Empty + num;
		}
		if (piecekuang == null)
		{
			piecekuang = base.gameObject.GetComponent<UISprite>();
		}
		if (!(piecekuang == null))
		{
			if (pd.id % 2 == 0)
			{
				piecekuang.spriteName = "JS_jiangLi_Z";
			}
			else
			{
				piecekuang.spriteName = "JS_jiangLi_S";
			}
		}
	}

	private void Start()
	{
		itembtn.onClick = OnClickitembtn;
	}

	public void OnClickitembtn(GameObject btn)
	{
		MonoInstance<AudioController>.instance.play(AudioType.UI_BTN, 0f);
		if (MidLoading.loadlevel == 2)
		{
			GameUIController.instance.enable_pieceui(curpiecedata);
		}
		else if (MidLoading.loadlevel == 0)
		{
			MenuUIController.instance.enable_pieceui(curpiecedata);
		}
	}
}
